<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/taglibs.jsp" %>
<%
    response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/page/common/include.jsp"></jsp:include>
<script language="javascript" type="text/javascript">

$(document).ready(function(){
	
	/** 初始化新增Panel位置 */
	$("#addPanel").offset({
		top:30,
		left:($(window).width()-400)*0.5
	});
	
	/** 初始化新增Panel */
	$("#addPanel").panel({
		width:400,
		height:220
	});
	
});

/**
 * 验证系统编号是否已经存在
 */
function checkSysCode(obj){
	var sysCode = $.trim(obj.val());
	obj.val($.trim(obj.val()));
	if(sysCode != ''){
		$.ajax({
			url : '<%=request.getContextPath()%>/systemInfo/systemInfoAction!checkSysCode.do',
			type : 'post',
			dataType : 'text',
			cache : false,
			data : {
				sysCode : sysCode
			},
			success : function(data) {
				var j = JSON.parse(data);
				if (j.result == 'fail') {
					$.messager.alert('操作结果', j.msg, 'error');
					obj.val('');
				} 
			}
		});
	}
}

/**
 * 提交表单
 */
function formSubmit(){
	if(validateForm()){
		disableLinkButton();
		$('#addForm').ajaxSubmit({
			type:"POST",
			url: '<%=request.getContextPath()%>/systemInfo/systemInfoAction!addSystemInfo.do',
			success:function(data){
				enableLinkButton();
				var j = JSON.parse(data);
				if (j.result == 'success') {
					messageAlertInfo("操作结果","业务系统增加成功！",formClear);
				} else {
					messageAlertError("操作结果",j.msg);
				}
			}
		}); 
	}
}

/**
 * 表单验证
 */
function validateForm(){
	return true;
}

/**
 * 清空表单
 */
function formClear(){
	goToPage('<%=request.getContextPath()%>/systemInfo/systemInfoAction!initAddSystemInfo.do');
}

</script>
</head>

<body style="background: white;" >
		<div id="addPanel" style="position:absolute;padding-top: 10px" align="center">
				<form id="addForm">
			    	<table>
			    		<tr>
			    			<td>系统编号：</td>
			    			<td>
			    				<s:textfield name="systemInfo.sysCode" onblur="checkSysCode($(this))"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>系统名称：</td>
			    			<td>
			    				<s:textfield name="systemInfo.sysName"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>系统别名：</td>
			    			<td>
			    				<s:textfield name="systemInfo.sysAbbr"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>链接地址：</td>
			    			<td>
			    				<s:textfield name="systemInfo.sysUrl"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>排序号：</td>
			    			<td>
			    				<s:textfield name="systemInfo.orderIndex"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td colspan="2" align="center" style="padding-top: 10px;">
			    				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="formSubmit()">提交</a>
								<a class="easyui-linkbutton" data-options="iconCls:'icon-reload'" href="javascript:void(0)" onclick="formClear()">清空</a>
			    			</td>
			    		</tr>
			    	</table>
		    	</form>
		</div>
</body>
</html>